# frozen_string_literal: true

{{#generated_src_warning}}
{{generated_src_warning}}
{{/generated_src_warning}}
module {{module_name}}

  # When {{service_name}} returns an error response, the Ruby SDK constructs and raises an error.
  # These errors all extend {{module_name}}::Errors::ServiceError < {Aws::Errors::ServiceError}
  #
  # You can rescue all {{service_name}} errors using ServiceError:
  #
  #     begin
  #       # do stuff
  #     rescue {{module_name}}::Errors::ServiceError
  #       # rescues all {{service_name}} API errors
  #     end
  #
  #
  # ## Request Context
  # ServiceError objects have a {Aws::Errors::ServiceError#context #context} method that returns
  # information about the request that generated the error.
  # See {Seahorse::Client::RequestContext} for more information.
  #
  # ## Error Classes
  {{#errors}}
  {{=<% %>=}}
  # * {<% name %>}
  <%={{ }}=%>
  {{#query_or_query_compatible_service?}}
  {{#custom_error_class?}}
  #    * This error class is not used. `{{custom_error_class}}` is used during parsing instead.
  {{/custom_error_class?}}
  {{/query_or_query_compatible_service?}}
  {{/errors}}
  #
  # Additionally, error classes are dynamically generated for service errors based on the error code
  # if they are not defined above.
  module Errors

    extend Aws::Errors::DynamicErrors

    {{#errors}}
    {{#query_or_query_compatible_service?}}
    {{#custom_error_class?}}
    # @deprecated This error class is not used during parsing.
    #   Please use `{{custom_error_class}}` instead.
    {{/custom_error_class?}}
    {{/query_or_query_compatible_service?}}
    class {{name}} < ServiceError

      # @param [Seahorse::Client::RequestContext] context
      # @param [String] message
      # @param [{{data_type}}] data
      def initialize(context, message, data = Aws::EmptyStructure.new)
        super(context, message, data)
      end
      {{#members}}

      # @return [{{type}}]
      def {{name}}
        {{#shared}}@{{name}} || {{/shared}}@data[:{{name}}]
      end
      {{/members}}
      {{#retryable}}

      def retryable?
        true
      end
      {{/retryable}}
      {{#throttling}}

      def throttling?
        true
      end
      {{/throttling}}
    end

    {{/errors}}
  end
end
{{#customization_file_exists?}}

# Load customizations if they exist
require '{{customization_file_path}}'
{{/customization_file_exists?}}
